package com.lanou3g.musicenjoy.fragment;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.lanou3g.musicenjoy.R;
import com.lanou3g.musicenjoy.entity.Mp3Info;

import com.lanou3g.musicenjoy.eventbus.MyEvent;
import com.lanou3g.musicenjoy.utils.FindSongs;
import com.lanou3g.musicenjoy.utils.MyConfig;

import java.util.List;
import de.greenrobot.event.EventBus;

/**
 * Created by dllo on 15/10/30.
 */
public class ScanActivity extends Activity implements View.OnClickListener {
    private ImageView scanImageView;
    private TextView numTextView;
    private Button keyTextView;
    private Handler handler;
    private FindSongs finder;
    private List<Mp3Info> mp3Infos;

    int count;
    private Runnable runnable;
    int i = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_scan);
        Log.i("wwwww", "tttttt");
        scanImageView = (ImageView) findViewById(R.id.scanImageView);
        numTextView = (TextView) findViewById(R.id.numTextView);
        keyTextView = (Button) findViewById(R.id.keyTextView);
        keyTextView.setOnClickListener(this);
        scanImageView.setOnClickListener(this);

        handler = new Handler();

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.scanImageView:
                finish();
                break;
            case R.id.keyTextView:
                int what=1;
                EventBus.getDefault().post(new MyEvent.Flag(what));
                Log.i("xixin", what + "000");
                handler.postDelayed(runnable11, 100);
                break;
        }



    }
//
    Runnable runnable11 = new Runnable() {
        @Override
        public void run() {
            if (i > 30) {
                handler.removeCallbacks(runnable11);
            } else {
                handler.postDelayed(runnable11,100);
                i++;
                numTextView.setText(i + "");

            }
        }
    };

}
